Skip to content

Conversation

immrsd
Copy link
Collaborator

@immrsd immrsd commented Feb 25, 2025

Adds fuzz test cases for ERC1155

@immrsd immrsd requested a review from ericnordelo February 25, 2025 12:56
@immrsd immrsd self-assigned this Feb 25, 2025
Copy link

codecov bot commented Feb 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.00%. Comparing base (cbfda3c) to head (5aaded9).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1348   +/-   ##
=======================================
  Coverage   93.00%   93.00%           
=======================================
  Files          80       80           
  Lines        2230     2230           
=======================================
  Hits         2074     2074           
  Misses        156      156           

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cbfda3c...5aaded9. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@ericnordelo ericnordelo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR looks good @immrsd, but let's use 0.38.0 feature for fuzzing to avoid the extra boilerplate.

values: Span<u256>,
}

fn prepare_tokens(ids_len_seed: u32, value_mult_seed: u32) -> TokenList {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to avoid this by using the new Fuzzing derivable trait from foundry 0.38.0. Let's update that before merging this to avoid the extra boilerplate.

@@ -71,3 +71,13 @@ pub fn assert_entrypoint_not_found_error<T, +Drop<T>>(
panic!("{selector} call was expected to fail, but succeeded");
}
}

/// Creates and returns a new array consisting of the given `element` repeated `n_times` times.
pub fn repeat<T, N, +Copy<T>, +Drop<T>, +Into<N, u256>>(element: T, n_times: N) -> Array<T> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should export this as part of our external API from testing, it should be an internal test_common item instead. We don't want the testing API to grow to big, so we should include utilities that will be potentially often used, and I think this is not the case.

Copy link
Member

@ericnordelo ericnordelo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@immrsd immrsd merged commit 0969a55 into OpenZeppelin:main Jul 10, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants